package itheima.com.HashSetTest;

import java.util.HashMap;
import java.util.Map;
import java.util.Set;

public class HashMapDemo05 {
    public static void main(String[] args) {
        HashMap<Student,String> hm = new HashMap<>();
        Student s1 = new Student("鸣人",28);
        Student s2 = new Student("晓",35);
        Student s3 = new Student("路飞",30);
        Student s4 = new Student("艾尼路",36);

        hm.put(s1,"城隍庙");
        hm.put(s2,"太子庙");
        hm.put(s3,"刑法场");
        hm.put(s4,"路之友");

        Set<Student> keys = hm.keySet();
        for (Student key : keys) {
            String value = hm.get(key);
            System.out.println(key+value);
        }
        System.out.println("-----------");
        Set<Map.Entry<Student, String>> entries = hm.entrySet();
        for (Map.Entry<Student, String> entry : entries) {
            Student key = entry.getKey();
            String value = entry.getValue();
            System.out.println(key+value);
        }
        System.out.println("-----------");
        hm.forEach((Student key,String value)->{
            System.out.println(key+value);
        });
    }
}
